package com.yc.spring.mapper;

import com.yc.spring.biz.UserBiz;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Data
@Repository
@Lazy
@Scope("prototpe")
@Primary
public class UserMapper {
    String myName="张三";
//    @Autowired
//    UserBiz userBiz;
    public UserMapper() {
        System.out.println("=============UserMapper constructor============"+myName);
    }

    //构造函数之后执行的方法
    @PostConstruct
    public void init(){
        //构造函数-》java对象的初始化 jvm的初始化
        //@PostConstruct-》Spring的初始化
        //会在内部属性完成Spring注入后再执行
        System.out.println("========UserMapper.init======="+myName);
    }
    @PreDestroy
    public void finish(){
        System.out.println("========UserMapper.finish======"+myName);
    }
    public String login(String username, String password){
        System.out.println("========UserMapper.login======");
        return "注册成功";
    }
    public void reg() {
        System.out.println("========UserMapper.reg=======");
    }
    public void query(){
        Object o=100;
        String s=(String)o;
        System.out.println("========查询=======");
    }
    /*
    上述拦截类似于
    try{
    前置拦截
    业务方法
    返回拦截
    }catch(Exception e){
    异常拦截
    }finally
    后置拦截
     */
}
